#pragma once
#include "../DefinesCore.hpp"
#include "Message.hpp"
#include <list>

CYBERTRON_BEGIN

class SocketUdpReceiverImpl;

class SocketUdpReceiver
{
public:
	SocketUdpReceiver(bool bSupportMessageSplit = true);
	virtual ~SocketUdpReceiver();

	bool initialize(
		int port, 
		// -1 means every message will be cached.
		int numMaximalMessageCache = -1);
	void clear();

	void takeAwayMessages(
		std::list<std::string>& messages);

	void takeAwayMessages(
		std::list<std::shared_ptr<Message> >& messages);

private:
	SocketUdpReceiver(const SocketUdpReceiver&);
	SocketUdpReceiver& operator = (const SocketUdpReceiver&);

private:
	SocketUdpReceiverImpl* mpImpl;
};

CYBERTRON_END
